package com.lmx.repoDomain.repository;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import javax.annotation.PostConstruct;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lmx.common.context.ActionContextHolder;
import com.lmx.common.util.CommonUtil;
import com.lmx.persistence.service.CommonService;
import com.lmx.persistence.service.NursingService;
import com.lmx.repoDomain.tmodel.NursingLog;
import com.lmx.repoDomain.tmodel.NursingPlanServiceItem;

import io.katharsis.queryParams.QueryParams;
import io.katharsis.repository.annotations.JsonApiFindAll;
import io.katharsis.repository.annotations.JsonApiResourceRepository;
import io.katharsis.repository.annotations.JsonApiSave;

@JsonApiResourceRepository(NursingLog.class)
@Component
public class NursingLogRepository extends BaseRepository<NursingLog> {
	
    @Autowired
    protected CommonService commonService;
	@Autowired
	private NursingService nursingService;

	@PostConstruct
	public void init() {
		dslJpaService.setEntityClass(NursingLog.class);
	}

	@Override
	@JsonApiSave
	public NursingLog save(NursingLog log) {		
        if(log.getId() == null){
        	log.setRecordTime(CommonUtil.getCurrTimes());
    		if (log.getNursingDate() == null) {
    			log.setNursingDate(CommonUtil.getCurrTimes());
    		}
            dslJpaService.create(log);
        }else {
        	log.setRecordTime(CommonUtil.getCurrTimes());
            dslJpaService.update(log);
        }		
		return log;
	}
	

	
	
}

























